package com.WFinstitute.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.WFinstitute.domain.Test;
import com.WFinstitute.repository.TestRepository;
import com.WFinstitute.service.TestService;
import com.WFinstitute.util.Page;



/***
 * 
 * @author cp.hlg.pf.kun
 * @time   2016-1-21 下午2:26:06
 */
@Service
public class TestServiceImpl implements TestService{
	@Resource
	private TestRepository  testRepository;


	@Override
	public Test addTest(Test test) {
		return testRepository.save(test);
	}

	@Override
	public List<Test> findTestList() {
		return testRepository.findAll();
	}

	@Override
	public Test updateTest(Test test) {
		return (Test)testRepository.update(test);
	}

	@Override
	public Test findTestById(Integer id) {
		return testRepository.findOne(id);
	}

	@Override
	public Page<Test> findTestList(Integer pageSize,Integer pageIndex, String name) {
		String jpql="select t from Test t where t.name like '%"+name+"%'";
		return testRepository.getAllPage(jpql, null, pageSize, pageIndex);
	}
	

}
